﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using VehicleManagement.Models;
using VehicleManagement.Codes;
using System.Collections;

namespace VehicleManagement.ControllersServices
{
    public class FinanManInfoServices
    {
        public IList<FinanManInfo> GetAllFinanMan()
        {
            IList<FinanManInfo> lstModel = SqlMapperManager.Instance.Get().QueryForList<FinanManInfo>("SELECT_FINANMANINFO", null);
            return lstModel.ToList();       
        }

        public IList<FinanManInfo> GetAllFinanManInfo(Hashtable ht)
        {
            IList<FinanManInfo> lstFinanman = new List<FinanManInfo> { };
            lstFinanman = SqlMapperManager.Instance.Get().QueryForList<FinanManInfo>("SEARCH_FINANMANINFO", ht);
            return lstFinanman;
        }

        /// <summary>
        /// 获取财务人员信息
        /// </summary>
        /// <param name="id">财务人员ID</param>
        /// <returns></returns>
        public FinanManInfo GetFinanManInfo(int id)
        {
            IList<FinanManInfo> lstModel = SqlMapperManager.Instance.Get().QueryForList<FinanManInfo>("SELECT_FINANMANINFO_BY_ID", id);
            FinanManInfo finanManInfo = lstModel.Where(u => u.FinanManID == id).First();
            return finanManInfo;      
        }

        public void AddFinanMan(FinanManInfo FinanMan)
        {
            object obj = SqlMapperManager.Instance.Get().Insert("INSERT_FINANMAN", FinanMan);
        }

        /// <summary>
        /// 根据财务人员ID，查看财务人员详细信息，并返回视图
        /// </summary>
        /// <param name="id">财务人员的ID</param>
        /// <returns>财务人员信息详细视图</returns>
           public FinanManInfo FinanManDetails(int id)
            {
            IList<FinanManInfo> lstModel = SqlMapperManager.Instance.Get().QueryForList<FinanManInfo>("SELECT_FINANMANINFO_BY_ID", id);
            FinanManInfo finanmanInfo = lstModel.Where(u => u.FinanManID == id).First();
            return finanmanInfo;
            }

           public FinanManInfo ShowEdit(int id)
           {
               IList<FinanManInfo> lstModel = SqlMapperManager.Instance.Get().QueryForList<FinanManInfo>("SELECT_FINANMANINFO_FOR_UPDATE", null);
               FinanManInfo finanmanInfo = lstModel.Where(u => u.FinanManID == id).First();
               return finanmanInfo;
           }

           /// <summary>
           /// 财务人员信息修改
           /// </summary>
           /// <param name="id">财务人员ID</param>
           /// <param name="driveriofo">返回财务人员类</param>
           /// <returns>修改财务人员的视图</returns>
           public void UpDate(FinanManInfo finanmaniofo)
           { 
               SqlMapperManager.Instance.Get().Update("UPDATE_FINANMANINFO", finanmaniofo); 
           }


            /// <summary>
        /// 根据财务人员的ID，删除财务人员
        /// </summary>
        /// <param name="id">财务人员ID</param>
        /// <returns></returns>
           public int DeleteFinan(int id)
           {
              return SqlMapperManager.Instance.Get().Delete("DELETE_FINANMANINFO", id);
           }



           public int CountAllFinanmaninfo(Hashtable ht)
           {
               return GetAllFinanManInfo(ht).Count;
           }

           public IList<FinanManInfo> GetAllFinanManInfo(Hashtable ht, int skip, int max)
           {
               IList<FinanManInfo> lstFinanman = SqlMapperManager.Instance.Get().QueryForList<FinanManInfo>("SEARCH_FINANMANINFO", ht,skip,max);
               return lstFinanman;
           }
    }
}